#ifndef GEOGAME_H
#define GEOGAME_H

#include <vector>
#include <fstream>

#include "../Screen.h"
#include "../ContentManager.h"
#include "../DrawHelper.h"
#include "MainMenu.h"

/*
Geogame in its present form is an editor for manipulating lines that will ultimately turn into a game.
*/
class Geopoint;

class Geogame : public Screen
{
    // Fields
    public:
    private:
        std::vector<Geopoint*> points;
        std::vector<Geopoint*> smoothPoints;        // Points used to draw a smoother appearing line
        int mode;                                   // Modes: 0 - Place lines, 1 - modify lines
        int mouseX, mouseY;                         // Mouse position updated by handleEvents for the rest of class to use
        int hitboxRange;                            // Hitbox range for point selection
        Geopoint* selectedPoint;                    // Store the position of the currently selected point
        unsigned int selectedPointIndex;            // Index number of point as stored in vector array
        bool isSelected;                            // If a point has been selected
        float sceneMoveDist;                        // Distance to move scene

    // Methods
    public:
        Geogame();
        virtual ~Geogame(){};
        void draw();
        void update(Uint32* deltaTime);
        void handleEvents(SDL_Event* event);
    private:
        bool load(std::string lfile);               // Load points from file
        bool save(std::string sfile);               // Save points to file
        void smoothLine();                          // Smooth the drawn line to look a little nicer
        void createPoint();                         // Create a point at (mouseX, mouseY)
        void movePoint();                           // Move currently selected point to (mouseX, mouseY)
};

class Geopoint
{
    public:
        int first;
        int second;
        float slope;
    public:
        Geopoint()
        {
            first = 0; second = 0; slope = 0;
        }
        Geopoint(int first, int second) : first(first), second(second) {}
        virtual ~Geopoint(){};
        /*
        bool operator==(Geopoint &other) const
        {
            if (first == other.first && second == other.second)
                return true;
            else
                return false;
        }
        */
};

#endif

